package cate.game.role.res.worldtree.share;

import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

@NoteClass(value = "英雄背包格子PO")
public class HeroShareBagBox {

    @NoteField(value = "格子位置")
    public int pos;

    @NoteField(value = "格子中英雄的唯一id")
    public String heroUid;

    @NoteField(value = "格子的倒计时")
    public long leftTime;

    public HeroShareBagBox() {}

    public HeroShareBagBox(int pos) {
        this.pos = pos;
    }

    @JsonIgnore
    public boolean isBoxEmpty() {
        return StringUtils.isBlank(this.heroUid);
    }

    @JsonIgnore
    public boolean isBoxColding() {
        return System.currentTimeMillis() < this.leftTime;
    }

    public void addHero(String uid) {
        this.heroUid = uid;
    }

    public void addCD(long cd) {
        this.heroUid = "";
        leftTime = cd;
    }

    public void cleanBox() {
        this.heroUid = "";
        leftTime = 0;
    }
}
